﻿Imports System.IO
Imports System.Globalization

Partial Public Class Occupency_Monthly
    Inherits System.Web.UI.Page

    Dim clsGet As New ClassFunctionGetData
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim lbPage As Label = CType(Master.FindControl("lbPage"), Label)
            lbPage.Text = "OCCUPENCY MONTHLY REPORT"
            For i As Integer = 0 To 4
                With ddlYear
                    .Items.Insert(i, Date.Now.AddYears(i - 2).Year)
                    .Items(i).Value = Date.Now.AddYears(i - 2).Year
                End With
            Next
            ddlYear.SelectedIndex = 2
            If Not (ddlMonth.Items.FindByValue(Date.Now.Month) Is Nothing) Then
                ddlMonth.SelectedValue = Date.Now.Month
            End If

        End If
    End Sub
    Private Sub MainPage_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        Dim ds As DataSet = Session("UserData")
        If Not (ds Is Nothing) Then
            Page.MasterPageFile = clsGet.GetMaster_Page(ds.Tables(0).Rows(0).Item("User_Name").ToString(), "M")
        End If
    End Sub


    Private Sub btnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrint.Click
        Dim service As New _ReportingService.Report

        Dim optWindow As String = "left=0,top=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no"
        Dim Orientation As Boolean = True
        Dim ReportName As String = String.Empty
        Dim reportDataSource As String = String.Empty
        Dim paraName As String = String.Empty
        Dim paraValue As String = String.Empty
        Dim reportType As String = String.Empty
        Dim urlDisplay As String = String.Empty
        Dim dsReport As New DataSet
        Dim LCT_TIME As String = "0"
        Dim LCT_OCC As String = "0"
        Dim LCT_OVER As String = "0"
        Dim LCT_ACT As String = "0"
        Dim BCT_TIME As String = "0"
        Dim BCT_OCC As String = "0"
        dsReport.Tables.Add(Get_Value(LCT_TIME, LCT_OCC, LCT_OVER, LCT_ACT, BCT_TIME, BCT_OCC))
        dsReport.AcceptChanges()

        ReportName = "Occupency_Monthly.rdlc"
        ' dsReport = New DataSet
        reportDataSource = "Occupency_Value"
        LCT_ACT = (((CDbl((CLng((LCT_TIME - LCT_OVER)) \ 60) & "." & (((CLng((LCT_TIME - LCT_OVER)) Mod 60) / 60) * 100).ToString("00"))) / ((CInt(LCT_OCC)) * 24)) * 100).ToString("################.00")
        LCT_OCC = (((CDbl((CLng(LCT_TIME) \ 60) & "." & (((CLng(LCT_TIME) Mod 60) / 60) * 100).ToString("00"))) / ((CInt(LCT_OCC)) * 24)) * 100).ToString("################.00")
        BCT_OCC = (((CDbl((CLng(BCT_TIME) \ 60) & "." & (((CLng(BCT_TIME) Mod 60) / 60) * 100).ToString("00"))) / ((CInt(BCT_OCC)) * 24)) * 100).ToString("################.00")
        LCT_TIME = (CInt(LCT_TIME) \ 60) & ":" & (CInt(LCT_TIME) Mod 60).ToString("00")
        BCT_TIME = (CInt(BCT_TIME) \ 60) & ":" & (CInt(BCT_TIME) Mod 60).ToString("00")
        LCT_OVER = (CInt(LCT_OVER) \ 60) & ":" & (CInt(LCT_OVER) Mod 60).ToString("00")
        paraName = "Month;LCT_TIME;LCT_OCC;LCT_OVER;LCT_ACT;BCT_TIME;BCT_OCC;DateTimeNow"
        paraValue = ddlMonth.SelectedItem.Text & " " & CInt(ddlYear.SelectedValue) & ";" & LCT_TIME & ";" & LCT_OCC & ";" & LCT_OVER & ";" & LCT_ACT & ";" & BCT_TIME & ";" & BCT_OCC & ";" & DateTime.Now.ToString()
        Orientation = True
        reportType = radioType.SelectedValue

        urlDisplay = service.CreateReporting(dsReport, reportDataSource, reportType, ReportName, paraName, paraValue, Orientation, "")

        Dim oldFile As String = String.Empty
        oldFile = Server.MapPath(urlDisplay)
        Dim fileInfo As FileInfo = New FileInfo(oldFile)
        Dim reportPath As String = "../WriteReport/"

        Dim newFileName As String = DateTime.Now.ToString("_yyMMdd_HHmmss", New CultureInfo("en-US"))
        newFileName = "Occupency_Report" & newFileName

        If fileInfo.Exists Then
            fileInfo.MoveTo(fileInfo.DirectoryName & "/" & newFileName & fileInfo.Extension)
            urlDisplay = reportPath & newFileName & fileInfo.Extension
        End If

        ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "myscript", "window.open('" + urlDisplay + "','_blank','" + optWindow + "');", True)
    End Sub

    Private Function Get_Value(ByRef LCT_TIME As String, ByRef LCT_OCC As String, ByRef LCT_OVER As String, ByRef LCT_ACT As String, ByRef BCT_TIME As String, ByRef BCT_OCC As String) As DataTable
        Dim dt As DataTable = Create()
        Dim dr As DataRow = dt.NewRow()
        Dim dtw As DataTable = clsGet.Get_OCC_monthly("1", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "00", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "32")
        If (dtw.Rows.Count > 0) Then
            dr.Item("LCT_Wharf_no") = "00004"
            dr.Item("LCT_Wharf_name") = "1"
            dr.Item("LCT_VOY") = dtw.Rows.Count
            Dim sum As Long = 0
            Dim SumOver As Long = 0
            For Each dd As DataRow In dtw.Rows
                Dim Berthing_DATETIME As String = dd.Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dd.Item("Berthing_Date")).ToString("MMdd") & dd.Item("Berthing_TimeTo").ToString.Split(":")(0) & dd.Item("Berthing_TimeTo").ToString.Split(":")(1)
                Dim Depart_DateTIME As String = "20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & dd.Item("Depart_actual_Date").ToString.Substring(3, 2) & dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & dd.Item("Depart_actual_Time").ToString.Split(":")(0) & dd.Item("Depart_actual_Time").ToString.Split(":")(1)
                Dim ts As Long = 0
                Dim Berthing_Date As String = ""
                Dim Berthing_Time As String = ""
                Dim Depart_Date As String = ""
                Dim Depart_Time As String = ""
                If (CLng(Berthing_DATETIME) < CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "010000")) Then
                    If (CLng(Depart_DateTIME) > CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "310000")) Then
                        ts = DateDiff("n", "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00", DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 23:59")
                        Berthing_Date = "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Berthing_Time = "00:00"
                        Depart_Date = DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Depart_Time = "23:59"
                    Else
                        ts = DateDiff("n", "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00", dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                        Berthing_Date = "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Berthing_Time = "00:00"
                        Depart_Date = dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2)
                        Depart_Time = dd.Item("Depart_actual_Time")
                    End If

                Else
                    If (CLng(Depart_DateTIME) > CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "310000")) Then
                        ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00")
                        Berthing_Date = dd.Item("Berthing_Date")
                        Berthing_Time = dd.Item("Berthing_TimeTo")
                        Depart_Date = DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Depart_Time = "23:59"
                    Else
                        ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                        Berthing_Date = dd.Item("Berthing_Date")
                        Berthing_Time = dd.Item("Berthing_TimeTo")
                        Depart_Date = dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2)
                        Depart_Time = dd.Item("Depart_actual_Time")
                    End If

                End If

                sum += ts
                Dim dtOver As DataTable = clsGet.Get_OCC_monthly_ForOVerLab("1", Berthing_DATETIME, Depart_DateTIME)
                If (dtOver.Rows.Count > 0) Then
                    For i As Integer = 0 To dtOver.Rows.Count - 1
                        If (CLng(dtOver.Rows(i).Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dtOver.Rows(i).Item("Berthing_Date")).ToString("MMdd")) > CLng(Berthing_Date.Split(" ")(2) & CDate(Berthing_Date).ToString("MMdd"))) Then
                            If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng("20" & Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                            ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                Else
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                            End If
                        ElseIf (CLng(dtOver.Rows(i).Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dtOver.Rows(i).Item("Berthing_Date")).ToString("MMdd")) = CLng(Berthing_Date.Split(" ")(2) & CDate(Berthing_Date).ToString("MMdd"))) Then
                            If (CLng(dtOver.Rows(i).Item("Berthing_TimeTo").ToString.Split(":")(0) & dtOver.Rows(i).Item("Berthing_TimeTo").ToString.Split(":")(1)) > CLng(Berthing_Time.Split(":")(0) & Berthing_Time.Split(":")(1))) Then
                                If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                        ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Berthing_Date & " " & Depart_Time)
                                    Else
                                        ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                    End If
                                Else
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                        ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, Depart_Date & " " & Depart_Time)
                                    Else
                                        ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                    End If
                                Else
                                    ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            End If

                        Else
                            If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                            ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                    ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, Berthing_Date & " " & Berthing_Time)
                                Else
                                    ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                            End If
                        End If
                        SumOver = ts
                    Next
                End If
            Next
            LCT_TIME = CLng(LCT_TIME) + sum
            LCT_OVER = CLng(LCT_OVER) + SumOver
            LCT_OCC = CInt(LCT_OCC) + Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00"))
            dr.Item("LCT_TIME") = (sum \ 60) & ":" & (sum Mod 60).ToString("00")
            dr.Item("LCT_OCC") = (((CDbl((sum \ 60) & "." & (((sum Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
            dr.Item("LCT_OVER") = (SumOver \ 60) & ":" & (SumOver Mod 60).ToString("00")
            dr.Item("LCT_ACT") = (((CDbl(((sum - SumOver) \ 60) & "." & ((((sum - SumOver) Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
        Else
            dr.Item("LCT_Wharf_no") = "00004"
            dr.Item("LCT_Wharf_name") = "1"
            dr.Item("LCT_VOY") = "0"
            dr.Item("LCT_TIME") = "00:00"
            dr.Item("LCT_OCC") = "0.0"
            dr.Item("LCT_OVER") = "0.0"
            dr.Item("LCT_ACT") = "0.0"
        End If
        dt.Rows.Add(dr)
        dt.AcceptChanges()

        dr = dt.NewRow()
        dtw = clsGet.Get_OCC_monthly("2A", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "00", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "32")
        If (dtw.Rows.Count > 0) Then
            dr.Item("LCT_Wharf_no") = "00005"
            dr.Item("LCT_Wharf_name") = "2A"
            dr.Item("LCT_VOY") = dtw.Rows.Count
            Dim sum As Long = 0
            Dim SumOver As Long = 0
            For Each dd As DataRow In dtw.Rows
                Dim Berthing_DATETIME As String = dd.Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dd.Item("Berthing_Date")).ToString("MMdd") & dd.Item("Berthing_TimeTo").ToString.Split(":")(0) & dd.Item("Berthing_TimeTo").ToString.Split(":")(1)
                Dim Depart_DateTIME As String = "20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & dd.Item("Depart_actual_Date").ToString.Substring(3, 2) & dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & dd.Item("Depart_actual_Time").ToString.Split(":")(0) & dd.Item("Depart_actual_Time").ToString.Split(":")(1)
                Dim ts As Long = 0
                Dim Berthing_Date As String = ""
                Dim Berthing_Time As String = ""
                Dim Depart_Date As String = ""
                Dim Depart_Time As String = ""
                If (CLng(Berthing_DATETIME) < CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "010000")) Then
                    If (CLng(Depart_DateTIME) > CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "310000")) Then
                        ts = DateDiff("n", "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00", DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 23:59")
                        Berthing_Date = "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Berthing_Time = "00:00"
                        Depart_Date = DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Depart_Time = "23:59"
                    Else
                        ts = DateDiff("n", "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00", dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                        Berthing_Date = "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Berthing_Time = "00:00"
                        Depart_Date = dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2)
                        Depart_Time = dd.Item("Depart_actual_Time")
                    End If

                Else
                    If (CLng(Depart_DateTIME) > CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "310000")) Then
                        ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00")
                        Berthing_Date = dd.Item("Berthing_Date")
                        Berthing_Time = dd.Item("Berthing_TimeTo")
                        Depart_Date = DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Depart_Time = "23:59"
                    Else
                        ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                        Berthing_Date = dd.Item("Berthing_Date")
                        Berthing_Time = dd.Item("Berthing_TimeTo")
                        Depart_Date = dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2)
                        Depart_Time = dd.Item("Depart_actual_Time")
                    End If

                End If

                sum += ts
                Dim dtOver As DataTable = clsGet.Get_OCC_monthly_ForOVerLab("2A", Berthing_DATETIME, Depart_DateTIME)
                If (dtOver.Rows.Count > 0) Then
                    For i As Integer = 0 To dtOver.Rows.Count - 1
                        If (CLng(dtOver.Rows(i).Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dtOver.Rows(i).Item("Berthing_Date")).ToString("MMdd")) > CLng(Berthing_Date.Split(" ")(2) & CDate(Berthing_Date).ToString("MMdd"))) Then
                            If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng("20" & Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                            ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                Else
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                            End If
                        ElseIf (CLng(dtOver.Rows(i).Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dtOver.Rows(i).Item("Berthing_Date")).ToString("MMdd")) = CLng(Berthing_Date.Split(" ")(2) & CDate(Berthing_Date).ToString("MMdd"))) Then
                            If (CLng(dtOver.Rows(i).Item("Berthing_TimeTo").ToString.Split(":")(0) & dtOver.Rows(i).Item("Berthing_TimeTo").ToString.Split(":")(1)) > CLng(Berthing_Time.Split(":")(0) & Berthing_Time.Split(":")(1))) Then
                                If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                        ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Berthing_Date & " " & Depart_Time)
                                    Else
                                        ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                    End If
                                Else
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                        ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, Depart_Date & " " & Depart_Time)
                                    Else
                                        ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                    End If
                                Else
                                    ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            End If

                        Else
                            If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                            ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                    ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, Berthing_Date & " " & Berthing_Time)
                                Else
                                    ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                            End If
                        End If
                        SumOver = ts
                    Next
                End If
            Next
            LCT_TIME = CLng(LCT_TIME) + sum
            LCT_OVER = CLng(LCT_OVER) + SumOver
            LCT_OCC = CInt(LCT_OCC) + Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00"))
            dr.Item("LCT_TIME") = (sum \ 60) & ":" & (sum Mod 60).ToString("00")
            dr.Item("LCT_OCC") = (((CDbl((sum \ 60) & "." & (((sum Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
            dr.Item("LCT_OVER") = (SumOver \ 60) & ":" & (SumOver Mod 60).ToString("00")
            dr.Item("LCT_ACT") = (((CDbl(((sum - SumOver) \ 60) & "." & ((((sum - SumOver) Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
        Else
            dr.Item("LCT_Wharf_no") = "00005"
            dr.Item("LCT_Wharf_name") = "2A"
            dr.Item("LCT_VOY") = "0"
            dr.Item("LCT_TIME") = "00:00"
            dr.Item("LCT_OCC") = "0.0"
            dr.Item("LCT_OVER") = "0.0"
            dr.Item("LCT_ACT") = "0.0"
        End If
        dt.Rows.Add(dr)
        dt.AcceptChanges()

        dr = dt.NewRow()
        dtw = clsGet.Get_OCC_monthly("2B", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "00", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "32")
        If (dtw.Rows.Count > 0) Then
            dr.Item("LCT_Wharf_no") = "00006"
            dr.Item("LCT_Wharf_name") = "2B"
            dr.Item("LCT_VOY") = dtw.Rows.Count
            Dim sum As Long = 0
            Dim SumOver As Long = 0
            For Each dd As DataRow In dtw.Rows
                Dim Berthing_DATETIME As String = dd.Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dd.Item("Berthing_Date")).ToString("MMdd") & dd.Item("Berthing_TimeTo").ToString.Split(":")(0) & dd.Item("Berthing_TimeTo").ToString.Split(":")(1)
                Dim Depart_DateTIME As String = "20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & dd.Item("Depart_actual_Date").ToString.Substring(3, 2) & dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & dd.Item("Depart_actual_Time").ToString.Split(":")(0) & dd.Item("Depart_actual_Time").ToString.Split(":")(1)
                Dim ts As Long = 0
                Dim Berthing_Date As String = ""
                Dim Berthing_Time As String = ""
                Dim Depart_Date As String = ""
                Dim Depart_Time As String = ""
                If (CLng(Berthing_DATETIME) < CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "010000")) Then
                    If (CLng(Depart_DateTIME) > CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "310000")) Then
                        ts = DateDiff("n", "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00", DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 23:59")
                        Berthing_Date = "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Berthing_Time = "00:00"
                        Depart_Date = DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Depart_Time = "23:59"
                    Else
                        ts = DateDiff("n", "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00", dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                        Berthing_Date = "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Berthing_Time = "00:00"
                        Depart_Date = dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2)
                        Depart_Time = dd.Item("Depart_actual_Time")
                    End If

                Else
                    If (CLng(Depart_DateTIME) > CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "310000")) Then
                        ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00")
                        Berthing_Date = dd.Item("Berthing_Date")
                        Berthing_Time = dd.Item("Berthing_TimeTo")
                        Depart_Date = DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Depart_Time = "23:59"
                    Else
                        ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                        Berthing_Date = dd.Item("Berthing_Date")
                        Berthing_Time = dd.Item("Berthing_TimeTo")
                        Depart_Date = dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2)
                        Depart_Time = dd.Item("Depart_actual_Time")
                    End If

                End If

                sum += ts
                Dim dtOver As DataTable = clsGet.Get_OCC_monthly_ForOVerLab("2B", Berthing_DATETIME, Depart_DateTIME)
                If (dtOver.Rows.Count > 0) Then
                    For i As Integer = 0 To dtOver.Rows.Count - 1
                        If (CLng(dtOver.Rows(i).Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dtOver.Rows(i).Item("Berthing_Date")).ToString("MMdd")) > CLng(Berthing_Date.Split(" ")(2) & CDate(Berthing_Date).ToString("MMdd"))) Then
                            If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng("20" & Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                            ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                Else
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                            End If
                        ElseIf (CLng(dtOver.Rows(i).Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dtOver.Rows(i).Item("Berthing_Date")).ToString("MMdd")) = CLng(Berthing_Date.Split(" ")(2) & CDate(Berthing_Date).ToString("MMdd"))) Then
                            If (CLng(dtOver.Rows(i).Item("Berthing_TimeTo").ToString.Split(":")(0) & dtOver.Rows(i).Item("Berthing_TimeTo").ToString.Split(":")(1)) > CLng(Berthing_Time.Split(":")(0) & Berthing_Time.Split(":")(1))) Then
                                If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                        ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Berthing_Date & " " & Depart_Time)
                                    Else
                                        ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                    End If
                                Else
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                        ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, Depart_Date & " " & Depart_Time)
                                    Else
                                        ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                    End If
                                Else
                                    ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            End If

                        Else
                            If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                            ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                    ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, Berthing_Date & " " & Berthing_Time)
                                Else
                                    ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                            End If
                        End If
                        SumOver = ts
                    Next
                End If
            Next
            LCT_TIME = CLng(LCT_TIME) + sum
            LCT_OVER = CLng(LCT_OVER) + SumOver
            LCT_OCC = CInt(LCT_OCC) + Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00"))
            dr.Item("LCT_TIME") = (sum \ 60) & ":" & (sum Mod 60).ToString("00")
            dr.Item("LCT_OCC") = (((CDbl((sum \ 60) & "." & (((sum Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")

            dr.Item("LCT_OVER") = (SumOver \ 60) & ":" & (SumOver Mod 60).ToString("00")
            dr.Item("LCT_ACT") = (((CDbl(((sum - SumOver) \ 60) & "." & ((((sum - SumOver) Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
        Else
            dr.Item("LCT_Wharf_no") = "00006"
            dr.Item("LCT_Wharf_name") = "2B"
            dr.Item("LCT_VOY") = "0"
            dr.Item("LCT_TIME") = "00:00"
            dr.Item("LCT_OCC") = "0.0"
            dr.Item("LCT_OVER") = "0.0"
            dr.Item("LCT_ACT") = "0.0"
        End If
        dt.Rows.Add(dr)
        dt.AcceptChanges()

        dr = dt.NewRow()
        dtw = clsGet.Get_OCC_monthly("3", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "00", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "32")
        If (dtw.Rows.Count > 0) Then
            dr.Item("LCT_Wharf_no") = "00007"
            dr.Item("LCT_Wharf_name") = "3"
            dr.Item("LCT_VOY") = dtw.Rows.Count
            Dim sum As Long = 0
            Dim SumOver As Long = 0
            For Each dd As DataRow In dtw.Rows
                Dim Berthing_DATETIME As String = dd.Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dd.Item("Berthing_Date")).ToString("MMdd") & dd.Item("Berthing_TimeTo").ToString.Split(":")(0) & dd.Item("Berthing_TimeTo").ToString.Split(":")(1)
                Dim Depart_DateTIME As String = "20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & dd.Item("Depart_actual_Date").ToString.Substring(3, 2) & dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & dd.Item("Depart_actual_Time").ToString.Split(":")(0) & dd.Item("Depart_actual_Time").ToString.Split(":")(1)
                Dim ts As Long = 0
                Dim Berthing_Date As String = ""
                Dim Berthing_Time As String = ""
                Dim Depart_Date As String = ""
                Dim Depart_Time As String = ""
                If (CLng(Berthing_DATETIME) < CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "010000")) Then
                    If (CLng(Depart_DateTIME) > CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "310000")) Then
                        ts = DateDiff("n", "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00", DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 23:59")
                        Berthing_Date = "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Berthing_Time = "00:00"
                        Depart_Date = DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Depart_Time = "23:59"
                    Else
                        ts = DateDiff("n", "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00", dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                        Berthing_Date = "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Berthing_Time = "00:00"
                        Depart_Date = dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2)
                        Depart_Time = dd.Item("Depart_actual_Time")
                    End If

                Else
                    If (CLng(Depart_DateTIME) > CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "310000")) Then
                        ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00")
                        Berthing_Date = dd.Item("Berthing_Date")
                        Berthing_Time = dd.Item("Berthing_TimeTo")
                        Depart_Date = DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Depart_Time = "23:59"
                    Else
                        ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                        Berthing_Date = dd.Item("Berthing_Date")
                        Berthing_Time = dd.Item("Berthing_TimeTo")
                        Depart_Date = dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2)
                        Depart_Time = dd.Item("Depart_actual_Time")
                    End If

                End If

                sum += ts
                Dim dtOver As DataTable = clsGet.Get_OCC_monthly_ForOVerLab("3", Berthing_DATETIME, Depart_DateTIME)
                If (dtOver.Rows.Count > 0) Then
                    For i As Integer = 0 To dtOver.Rows.Count - 1
                        If (CLng(dtOver.Rows(i).Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dtOver.Rows(i).Item("Berthing_Date")).ToString("MMdd")) > CLng(Berthing_Date.Split(" ")(2) & CDate(Berthing_Date).ToString("MMdd"))) Then
                            If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng("20" & Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                            ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                Else
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                            End If
                        ElseIf (CLng(dtOver.Rows(i).Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dtOver.Rows(i).Item("Berthing_Date")).ToString("MMdd")) = CLng(Berthing_Date.Split(" ")(2) & CDate(Berthing_Date).ToString("MMdd"))) Then
                            If (CLng(dtOver.Rows(i).Item("Berthing_TimeTo").ToString.Split(":")(0) & dtOver.Rows(i).Item("Berthing_TimeTo").ToString.Split(":")(1)) > CLng(Berthing_Time.Split(":")(0) & Berthing_Time.Split(":")(1))) Then
                                If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                        ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Berthing_Date & " " & Depart_Time)
                                    Else
                                        ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                    End If
                                Else
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                        ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, Depart_Date & " " & Depart_Time)
                                    Else
                                        ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                    End If
                                Else
                                    ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            End If

                        Else
                            If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                            ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                    ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, Berthing_Date & " " & Berthing_Time)
                                Else
                                    ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                            End If
                        End If
                        SumOver = ts
                    Next
                End If
            Next
            LCT_TIME = CLng(LCT_TIME) + sum
            LCT_OVER = CLng(LCT_OVER) + SumOver
            LCT_OCC = CInt(LCT_OCC) + Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00"))
            dr.Item("LCT_TIME") = (sum \ 60) & ":" & (sum Mod 60).ToString("00")
            dr.Item("LCT_OCC") = (((CDbl((sum \ 60) & "." & (((sum Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
            dr.Item("LCT_OVER") = (SumOver \ 60) & ":" & (SumOver Mod 60).ToString("00")
            dr.Item("LCT_ACT") = (((CDbl(((sum - SumOver) \ 60) & "." & ((((sum - SumOver) Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
        Else
            dr.Item("LCT_Wharf_no") = "00007"
            dr.Item("LCT_Wharf_name") = "3"
            dr.Item("LCT_VOY") = "0"
            dr.Item("LCT_TIME") = "00:00"
            dr.Item("LCT_OCC") = "0.0"
            dr.Item("LCT_OVER") = "0.0"
            dr.Item("LCT_ACT") = "0.0"
        End If
        dt.Rows.Add(dr)
        dt.AcceptChanges()

        dr = dt.NewRow()
        dtw = clsGet.Get_OCC_monthly("4", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "00", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "32")
        If (dtw.Rows.Count > 0) Then
            dr.Item("LCT_Wharf_no") = "00008"
            dr.Item("LCT_Wharf_name") = "4"
            dr.Item("LCT_VOY") = dtw.Rows.Count
            Dim sum As Long = 0
            Dim SumOver As Long = 0
            For Each dd As DataRow In dtw.Rows
                Dim Berthing_DATETIME As String = dd.Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dd.Item("Berthing_Date")).ToString("MMdd") & dd.Item("Berthing_TimeTo").ToString.Split(":")(0) & dd.Item("Berthing_TimeTo").ToString.Split(":")(1)
                Dim Depart_DateTIME As String = "20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & dd.Item("Depart_actual_Date").ToString.Substring(3, 2) & dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & dd.Item("Depart_actual_Time").ToString.Split(":")(0) & dd.Item("Depart_actual_Time").ToString.Split(":")(1)
                Dim ts As Long = 0
                Dim Berthing_Date As String = ""
                Dim Berthing_Time As String = ""
                Dim Depart_Date As String = ""
                Dim Depart_Time As String = ""
                If (CLng(Berthing_DATETIME) < CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "010000")) Then
                    If (CLng(Depart_DateTIME) > CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "310000")) Then
                        ts = DateDiff("n", "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00", DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 23:59")
                        Berthing_Date = "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Berthing_Time = "00:00"
                        Depart_Date = DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Depart_Time = "23:59"
                    Else
                        ts = DateDiff("n", "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00", dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                        Berthing_Date = "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Berthing_Time = "00:00"
                        Depart_Date = dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2)
                        Depart_Time = dd.Item("Depart_actual_Time")
                    End If

                Else
                    If (CLng(Depart_DateTIME) > CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "310000")) Then
                        ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00")
                        Berthing_Date = dd.Item("Berthing_Date")
                        Berthing_Time = dd.Item("Berthing_TimeTo")
                        Depart_Date = DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Depart_Time = "23:59"
                    Else
                        ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                        Berthing_Date = dd.Item("Berthing_Date")
                        Berthing_Time = dd.Item("Berthing_TimeTo")
                        Depart_Date = dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2)
                        Depart_Time = dd.Item("Depart_actual_Time")
                    End If

                End If

                sum += ts
                Dim dtOver As DataTable = clsGet.Get_OCC_monthly_ForOVerLab("4", Berthing_DATETIME, Depart_DateTIME)
                If (dtOver.Rows.Count > 0) Then
                    For i As Integer = 0 To dtOver.Rows.Count - 1
                        If (CLng(dtOver.Rows(i).Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dtOver.Rows(i).Item("Berthing_Date")).ToString("MMdd")) > CLng(Berthing_Date.Split(" ")(2) & CDate(Berthing_Date).ToString("MMdd"))) Then
                            If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng("20" & Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                            ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                Else
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                            End If
                        ElseIf (CLng(dtOver.Rows(i).Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dtOver.Rows(i).Item("Berthing_Date")).ToString("MMdd")) = CLng(Berthing_Date.Split(" ")(2) & CDate(Berthing_Date).ToString("MMdd"))) Then
                            If (CLng(dtOver.Rows(i).Item("Berthing_TimeTo").ToString.Split(":")(0) & dtOver.Rows(i).Item("Berthing_TimeTo").ToString.Split(":")(1)) > CLng(Berthing_Time.Split(":")(0) & Berthing_Time.Split(":")(1))) Then
                                If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                        ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Berthing_Date & " " & Depart_Time)
                                    Else
                                        ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                    End If
                                Else
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                        ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, Depart_Date & " " & Depart_Time)
                                    Else
                                        ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                    End If
                                Else
                                    ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            End If

                        Else
                            If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                            ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                    ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, Berthing_Date & " " & Berthing_Time)
                                Else
                                    ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                            End If
                        End If
                        SumOver = ts
                    Next
                End If
            Next
            LCT_TIME = CLng(LCT_TIME) + sum
            LCT_OVER = CLng(LCT_OVER) + SumOver
            LCT_OCC = CInt(LCT_OCC) + Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00"))
            dr.Item("LCT_TIME") = (sum \ 60) & ":" & (sum Mod 60).ToString("00")
            dr.Item("LCT_OCC") = (((CDbl((sum \ 60) & "." & (((sum Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
            dr.Item("LCT_OVER") = (SumOver \ 60) & ":" & (SumOver Mod 60).ToString("00")
            dr.Item("LCT_ACT") = (((CDbl(((sum - SumOver) \ 60) & "." & ((((sum - SumOver) Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
        Else
            dr.Item("LCT_Wharf_no") = "00008"
            dr.Item("LCT_Wharf_name") = "4"
            dr.Item("LCT_VOY") = "0"
            dr.Item("LCT_TIME") = "00:00"
            dr.Item("LCT_OCC") = "0.0"
            dr.Item("LCT_OVER") = "0.0"
            dr.Item("LCT_ACT") = "0.0"
        End If
        dt.Rows.Add(dr)
        dt.AcceptChanges()

        dr = dt.NewRow()
        dtw = clsGet.Get_OCC_monthly("5", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "00", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "32")
        If (dtw.Rows.Count > 0) Then
            dr.Item("LCT_Wharf_no") = "00009"
            dr.Item("LCT_Wharf_name") = "5"
            dr.Item("LCT_VOY") = dtw.Rows.Count
            Dim sum As Long = 0
            Dim SumOver As Long = 0
            For Each dd As DataRow In dtw.Rows
                Dim Berthing_DATETIME As String = dd.Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dd.Item("Berthing_Date")).ToString("MMdd") & dd.Item("Berthing_TimeTo").ToString.Split(":")(0) & dd.Item("Berthing_TimeTo").ToString.Split(":")(1)
                Dim Depart_DateTIME As String = "20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & dd.Item("Depart_actual_Date").ToString.Substring(3, 2) & dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & dd.Item("Depart_actual_Time").ToString.Split(":")(0) & dd.Item("Depart_actual_Time").ToString.Split(":")(1)
                Dim ts As Long = 0
                Dim Berthing_Date As String = ""
                Dim Berthing_Time As String = ""
                Dim Depart_Date As String = ""
                Dim Depart_Time As String = ""
                If (CLng(Berthing_DATETIME) < CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "010000")) Then
                    If (CLng(Depart_DateTIME) > CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "310000")) Then
                        ts = DateDiff("n", "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00", DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 23:59")
                        Berthing_Date = "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Berthing_Time = "00:00"
                        Depart_Date = DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Depart_Time = "23:59"
                    Else
                        ts = DateDiff("n", "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00", dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                        Berthing_Date = "01 " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Berthing_Time = "00:00"
                        Depart_Date = dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2)
                        Depart_Time = dd.Item("Depart_actual_Time")
                    End If

                Else
                    If (CLng(Depart_DateTIME) > CLng(ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "310000")) Then
                        ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue & " 00:00")
                        Berthing_Date = dd.Item("Berthing_Date")
                        Berthing_Time = dd.Item("Berthing_TimeTo")
                        Depart_Date = DateTime.DaysInMonth(ddlYear.SelectedValue, ddlMonth.SelectedValue) & " " & GetNameMonth(ddlMonth.SelectedValue) & " " & ddlYear.SelectedValue
                        Depart_Time = "23:59"
                    Else
                        ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                        Berthing_Date = dd.Item("Berthing_Date")
                        Berthing_Time = dd.Item("Berthing_TimeTo")
                        Depart_Date = dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2)
                        Depart_Time = dd.Item("Depart_actual_Time")
                    End If

                End If

                sum += ts
                Dim dtOver As DataTable = clsGet.Get_OCC_monthly_ForOVerLab("5", Berthing_DATETIME, Depart_DateTIME)
                If (dtOver.Rows.Count > 0) Then
                    For i As Integer = 0 To dtOver.Rows.Count - 1
                        If (CLng(dtOver.Rows(i).Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dtOver.Rows(i).Item("Berthing_Date")).ToString("MMdd")) > CLng(Berthing_Date.Split(" ")(2) & CDate(Berthing_Date).ToString("MMdd"))) Then
                            If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng("20" & Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                            ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                Else
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                            End If
                        ElseIf (CLng(dtOver.Rows(i).Item("Berthing_Date").ToString().Split(" ")(2) & CDate(dtOver.Rows(i).Item("Berthing_Date")).ToString("MMdd")) = CLng(Berthing_Date.Split(" ")(2) & CDate(Berthing_Date).ToString("MMdd"))) Then
                            If (CLng(dtOver.Rows(i).Item("Berthing_TimeTo").ToString.Split(":")(0) & dtOver.Rows(i).Item("Berthing_TimeTo").ToString.Split(":")(1)) > CLng(Berthing_Time.Split(":")(0) & Berthing_Time.Split(":")(1))) Then
                                If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                        ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), Berthing_Date & " " & Depart_Time)
                                    Else
                                        ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                    End If
                                Else
                                    ts = DateDiff("n", dtOver.Rows(i).Item("Berthing_Date") & " " & dtOver.Rows(i).Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                                ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                    If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                        ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, Depart_Date & " " & Depart_Time)
                                    Else
                                        ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                    End If
                                Else
                                    ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            End If

                        Else
                            If (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) > CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), Depart_Date & " " & Depart_Time)
                            ElseIf (CLng("20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2) & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2)) = CLng(Depart_Date.Split(" ")(2) & CDate(Depart_Date).ToString("MMdd"))) Then
                                If (CLng(dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(0) & dtOver.Rows(i).Item("Depart_Actual_Time").ToString.Split(":")(1)) > CLng(Depart_Time.Split(":")(0) & Depart_Time.Split(":")(1))) Then
                                    ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, Berthing_Date & " " & Berthing_Time)
                                Else
                                    ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                                End If
                            Else
                                ts = DateDiff("n", Berthing_Date & " " & Berthing_Time, dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dtOver.Rows(i).Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dtOver.Rows(i).Item("Depart_actual_Time"))
                            End If
                        End If
                        SumOver = ts
                    Next
                End If
            Next
            LCT_TIME = CLng(LCT_TIME) + sum
            LCT_OVER = CLng(LCT_OVER) + SumOver
            LCT_OCC = CInt(LCT_OCC) + Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00"))
            dr.Item("LCT_TIME") = (sum \ 60) & ":" & (sum Mod 60).ToString("00")
            dr.Item("LCT_OCC") = (((CDbl((sum \ 60) & "." & (((sum Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
            dr.Item("LCT_OVER") = (SumOver \ 60) & ":" & (SumOver Mod 60).ToString("00")
            dr.Item("LCT_ACT") = (((CDbl(((sum - SumOver) \ 60) & "." & ((((sum - SumOver) Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
        Else
            dr.Item("LCT_Wharf_no") = "00009"
            dr.Item("LCT_Wharf_name") = "5"
            dr.Item("LCT_VOY") = "0"
            dr.Item("LCT_TIME") = "00:00"
            dr.Item("LCT_OCC") = "0.0"
            dr.Item("LCT_OVER") = "0.0"
            dr.Item("LCT_ACT") = "0.0"
        End If
        dt.Rows.Add(dr)
        dt.AcceptChanges()

        dtw = clsGet.Get_OCC_monthly("7A", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "00", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "32")
        If (dtw.Rows.Count > 0) Then
            dt.Rows(0).Item("BCT_Wharf_no") = "00001"
            dt.Rows(0).Item("BCT_Wharf_name") = "7A"
            dt.Rows(0).Item("BCT_VOY") = dtw.Rows.Count
            Dim sum As Long = 0
            For Each dd As DataRow In dtw.Rows
                Dim ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                sum += ts
            Next
            BCT_TIME = CLng(BCT_TIME) + sum
            BCT_OCC = CInt(BCT_OCC) + Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00"))
            dt.Rows(0).Item("BCT_TIME") = (sum \ 60) & ":" & (sum Mod 60).ToString("00")
            dt.Rows(0).Item("BCT_OCC") = (((CDbl((sum \ 60) & "." & (((sum Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
        Else
            dt.Rows(0).Item("BCT_Wharf_no") = "00001"
            dt.Rows(0).Item("BCT_Wharf_name") = "7A"
            dt.Rows(0).Item("BCT_VOY") = "0"
            dt.Rows(0).Item("BCT_TIME") = "00:00"
            dt.Rows(0).Item("BCT_OCC") = "0.0"
        End If
        dt.AcceptChanges()

        dtw = clsGet.Get_OCC_monthly("7B", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "00", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "32")
        If (dtw.Rows.Count > 0) Then
            dt.Rows(1).Item("BCT_Wharf_no") = "00002"
            dt.Rows(1).Item("BCT_Wharf_name") = "7B"
            dt.Rows(1).Item("BCT_VOY") = dtw.Rows.Count
            Dim sum As Long = 0
            For Each dd As DataRow In dtw.Rows
                Dim ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                sum += ts
            Next
            BCT_TIME = CLng(BCT_TIME) + sum
            BCT_OCC = CInt(BCT_OCC) + Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00"))
            dt.Rows(1).Item("BCT_TIME") = (sum \ 60) & ":" & (sum Mod 60).ToString("00")
            dt.Rows(1).Item("BCT_OCC") = (((CDbl((sum \ 60) & "." & (((sum Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
        Else
            dt.Rows(1).Item("BCT_Wharf_no") = "00002"
            dt.Rows(1).Item("BCT_Wharf_name") = "7B"
            dt.Rows(1).Item("BCT_VOY") = "0"
            dt.Rows(1).Item("BCT_TIME") = "00:00"
            dt.Rows(1).Item("BCT_OCC") = "0.0"
        End If
        dt.AcceptChanges()

        dtw = clsGet.Get_OCC_monthly("8A1", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "00", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "32")
        If (dtw.Rows.Count > 0) Then
            dt.Rows(2).Item("BCT_Wharf_no") = "00003"
            dt.Rows(2).Item("BCT_Wharf_name") = "8A1"
            dt.Rows(2).Item("BCT_VOY") = dtw.Rows.Count
            Dim sum As Long = 0
            For Each dd As DataRow In dtw.Rows
                Dim ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                sum += ts
            Next
            BCT_TIME = CLng(BCT_TIME) + sum
            BCT_OCC = CInt(BCT_OCC) + Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00"))
            dt.Rows(2).Item("BCT_TIME") = (sum \ 60) & ":" & (sum Mod 60).ToString("00")
            dt.Rows(2).Item("BCT_OCC") = (((CDbl((sum \ 60) & "." & (((sum Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
        Else
            dt.Rows(2).Item("BCT_Wharf_no") = "00003"
            dt.Rows(2).Item("BCT_Wharf_name") = "8A1"
            dt.Rows(2).Item("BCT_VOY") = "0"
            dt.Rows(2).Item("BCT_TIME") = "00:00"
            dt.Rows(2).Item("BCT_OCC") = "0.0"
        End If
        dt.AcceptChanges()

        dtw = clsGet.Get_OCC_monthly("8A2", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "00", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "32")
        If (dtw.Rows.Count > 0) Then
            dt.Rows(3).Item("BCT_Wharf_no") = "00011"
            dt.Rows(3).Item("BCT_Wharf_name") = "8A2"
            dt.Rows(3).Item("BCT_VOY") = dtw.Rows.Count
            Dim sum As Long = 0
            For Each dd As DataRow In dtw.Rows
                Dim ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                sum += ts
            Next
            BCT_TIME = CLng(BCT_TIME) + sum
            BCT_OCC = CInt(BCT_OCC) + Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00"))
            dt.Rows(3).Item("BCT_TIME") = (sum \ 60) & ":" & (sum Mod 60).ToString("00")
            dt.Rows(3).Item("BCT_OCC") = (((CDbl((sum \ 60) & "." & (((sum Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
        Else
            dt.Rows(3).Item("BCT_Wharf_no") = "00011"
            dt.Rows(3).Item("BCT_Wharf_name") = "8A2"
            dt.Rows(3).Item("BCT_VOY") = "0"
            dt.Rows(3).Item("BCT_TIME") = "00:00"
            dt.Rows(3).Item("BCT_OCC") = "0.0"
        End If
        dt.AcceptChanges()

        dtw = clsGet.Get_OCC_monthly("8B1", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "00", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "32")
        If (dtw.Rows.Count > 0) Then
            dt.Rows(4).Item("BCT_Wharf_no") = "00010"
            dt.Rows(4).Item("BCT_Wharf_name") = "8B1"
            dt.Rows(4).Item("BCT_VOY") = dtw.Rows.Count
            Dim sum As Long = 0
            For Each dd As DataRow In dtw.Rows
                Dim ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                sum += ts
            Next
            BCT_TIME = CLng(BCT_TIME) + sum
            BCT_OCC = CInt(BCT_OCC) + Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00"))
            dt.Rows(4).Item("BCT_TIME") = (sum \ 60) & ":" & (sum Mod 60).ToString("00")
            dt.Rows(4).Item("BCT_OCC") = (((CDbl((sum \ 60) & "." & (((sum Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
        Else
            dt.Rows(4).Item("BCT_Wharf_no") = "00010"
            dt.Rows(4).Item("BCT_Wharf_name") = "8B1"
            dt.Rows(4).Item("BCT_VOY") = "0"
            dt.Rows(4).Item("BCT_TIME") = "00:00"
            dt.Rows(4).Item("BCT_OCC") = "0.0"
        End If
        dt.AcceptChanges()

        dtw = clsGet.Get_OCC_monthly("8B2", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "00", ddlYear.SelectedValue & CInt(ddlMonth.SelectedValue).ToString("00") & "32")
        If (dtw.Rows.Count > 0) Then
            dt.Rows(5).Item("BCT_Wharf_no") = "00012"
            dt.Rows(5).Item("BCT_Wharf_name") = "8B2"
            dt.Rows(5).Item("BCT_VOY") = dtw.Rows.Count
            Dim sum As Long = 0
            For Each dd As DataRow In dtw.Rows
                Dim ts = DateDiff("n", dd.Item("Berthing_Date") & " " & dd.Item("Berthing_TimeTo"), dd.Item("Depart_actual_Date").ToString.Substring(0, 2) & " " & GetNameMonth(dd.Item("Depart_actual_Date").ToString.Substring(3, 2)) & " 20" & dd.Item("Depart_actual_Date").ToString.Substring(6, 2) & " " & dd.Item("Depart_actual_Time"))
                sum += ts
            Next
            BCT_TIME = CLng(BCT_TIME) + sum
            BCT_OCC = CInt(BCT_OCC) + Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00"))
            dt.Rows(5).Item("BCT_TIME") = (sum \ 60) & ":" & (sum Mod 60).ToString("00")
            dt.Rows(5).Item("BCT_OCC") = (((CDbl((sum \ 60) & "." & (((sum Mod 60) / 60) * 100).ToString("00"))) / (Date.DaysInMonth(CInt(ddlYear.SelectedValue), CInt(ddlMonth.SelectedValue).ToString("00")) * 24)) * 100).ToString("##########.00")
        Else
            dt.Rows(5).Item("BCT_Wharf_no") = "00012"
            dt.Rows(5).Item("BCT_Wharf_name") = "8B2"
            dt.Rows(5).Item("BCT_VOY") = "0"
            dt.Rows(5).Item("BCT_TIME") = "00:00"
            dt.Rows(5).Item("BCT_OCC") = "0.0"
        End If
        dt.AcceptChanges()

        Return dt
    End Function

    Private Function Create() As DataTable
        Dim dt As New DataTable()
        dt.Columns.Add("LCT_Wharf_no", GetType(String))
        dt.Columns.Add("LCT_Wharf_name", GetType(String))
        dt.Columns.Add("LCT_VOY", GetType(String))
        dt.Columns.Add("LCT_TIME", GetType(String))
        dt.Columns.Add("LCT_OCC", GetType(String))
        dt.Columns.Add("LCT_OVER", GetType(String))
        dt.Columns.Add("LCT_ACT", GetType(String))
        dt.Columns.Add("BCT_Wharf_no", GetType(String))
        dt.Columns.Add("BCT_Wharf_name", GetType(String))
        dt.Columns.Add("BCT_VOY", GetType(String))
        dt.Columns.Add("BCT_TIME", GetType(String))
        dt.Columns.Add("BCT_OCC", GetType(String))
        dt.AcceptChanges()
        Return dt
    End Function

    Private Function GetNameMonth(ByVal Month As String) As String
        Try
            Select Case (CInt(Month).ToString("00"))
                Case "01"
                    Return "Jan"
                Case "02"
                    Return "Feb"
                Case "03"
                    Return "Mar"
                Case "04"
                    Return "Apr"
                Case "05"
                    Return "May"
                Case "06"
                    Return "Jun"
                Case "07"
                    Return "Jul"
                Case "08"
                    Return "Aug"
                Case "09"
                    Return "Sep"
                Case "10"
                    Return "Oct"
                Case "11"
                    Return "Nov"
                Case "12"
                    Return "Dec"
                Case Else
                    Return ""
            End Select
        Catch ex As Exception
            Return Month
        End Try

    End Function

End Class